{{template "../public/page_header.html" .}}

<link rel="stylesheet" type="text/css" href="/static/frontend/css/cart.css">
<script src="/static/frontend/js/cart.js"></script>
<!-- start banner_x -->
<div class="banner_x center">
    <a href="/" target="_blank">
        <div class="logo fl"><img src="/static/frontend/image/logo_top.png"></div>
    </a>
    <div class="my_cart fl ml40">我的购物车</div>
    <div class="tips fl ml20">温馨提示：产品是否购买成功，以最终下单为准哦，请尽快结算</div>
    <div class="clear"></div>
</div>
<div class="xiantiao"></div>
<div class="cartdetail">
    <div class="cartdetail_sub center clearfix">
        <table class="table">
            <tr class="th">
                <th>
                    <input type="checkbox" id="checkAll"/>
                    全选
                </th>
                <th>
                    商品名称
                </th>
                <th>单价</th>
                <th>数量</th>
                <th>小计</th>
                <th>操作</th>
            </tr>
        {{range $key,$value := .cartList}}
            <tr class="cart_list">
                <td>
                    <input type="checkbox" product_id="{{$value.Id}}"
                           product_color="{{$value.ProductColor}}"
                    {{if eq $value.Checked true}} checked {{end}} />
                </td>
                <td>
                    <div class="col_pic">
                        <img src="{{$value.ProductImg | formatImage}}"/>
                    </div>
                    <div class="col_title">
                    {{$value.Title}} -- {{$value.ProductColor}} {{$value.ProductVersion}}
                    </div>
                </td>
                <td class="price">
                {{$value.Price}}元
                </td>
                <td>
                    <div class="cart_number">
                        <div class="input_left decCart" product_id="{{$value.Id}}"
                             product_color="{{$value.ProductColor}}">-
                        </div>
                        <div class="input_center">
                            <input id="num" name="num" readonly="readonly"
                                   type="text" value="{{$value.Num}}"/>
                        </div>
                        <div class="input_right incCart" product_id="{{$value.Id}}"
                             product_color="{{$value.ProductColor}}">+
                        </div>
                    </div>
                </td>
                <td class="totalPrice">
                {{mul $value.Price $value.Num}}元
                </td>
                <td>
                    <span><a href="/cart/delCart?product_id={{$value.Id}}
                    &product_color={{$value.ProductColor}}"
                             class="delete"> 删除</a></span>
                </td>
            </tr>
        {{end}}
        </table>
    </div>
    <div class="checkoutpage mt20 center">
        <div class="tishi fl ml20">
            <ul>
                <li><a href="./liebiao.html">继续购物</a></li>
            </ul>
        </div>
        <div class="checkout fr">
            <div class="checkoutproduct fl">合计（不含运费）：<span id="allPrice">{{.allPrice}}元</span></div>
            <div class="gocheckout fr"><input class="jsan" type="submit" name="checkout" id="checkout" value="去结算"/></div>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </div>
</div>
<script>
    $(function () {
        $("#checkout").click(function () {
            var allPrice = parseFloat($("#allPrice").html());
            if (allPrice == 0) {
                alert('购物车没有选中去结算的商品')
            } else {
                location.href = "/buy/checkout";
            }
        })
    })
</script>
<!-- footer -->
{{template "../public/page_footer.html" .}}
</body>
</html>
